<?php

namespace catchAdmin\pc\controller;

use catchAdmin\pc\model\UserCompanyExt;
use catcher\base\CatchRequest as Request;
use catcher\CatchResponse;
use catcher\base\CatchController;
use catchAdmin\pc\model\WuZi as WuZiModel;
use think\Response;

class WuZi extends CatchController
{

    protected $wuZiModel;


    /**
     *
     * @time 2025/08/12 15:39
     * @param WuZiModel $wuZiModel
     * @return mixed
     */
    public function __construct(WuZiModel $wuZiModel)
    {
        $this->wuZiModel = $wuZiModel;
    }


    /**
     *
     * @time 2025/08/12 15:39
     * @return Response
     */
    public function index(): Response
    {
        return CatchResponse::paginate($this->wuZiModel->getList());
    }


    /**
     *
     * @time 2025/08/12 15:39
     * @param Request $request
     * @return Response
     */
    public function save(Request $request): Response
    {
        return CatchResponse::success((new UserCompanyExt())->saveData($request->post()));
//        return CatchResponse::success($this->wuZiModel->storeBy($request->post()));
    }


    /**
     *
     * @time 2025/08/12 15:39
     * @param $id
     * @return Response
     */
    public function read($id): Response
    {
        return CatchResponse::success($this->wuZiModel->findBy($id));
    }


    /**
     *
     * @time 2025/08/12 15:39
     * @param $id
     * @param Request $request
     * @return Response
     */
    public function update($id, Request $request): Response
    {
        return CatchResponse::success($this->wuZiModel->updateBy($id, $request->post()));
    }


    /**
     *
     * @time 2025/08/12 15:39
     * @param $id
     * @return Response
     */
    public function delete($id): Response
    {
        return CatchResponse::success($this->wuZiModel->deleteBy($id));
    }
}
